<template>
    <ul class="courseList">
        <li v-for="item, index in courseList" :key="index"><a @click="go(item)" class="clearfloat" target="_blank">

                <div class="fl red-text">
                    <div>
                        <div class="tag-wrap">
                            <Tag v-for="i,idx in item.tagNameList" :tag="i" :key="i" :index="idx" class="my-tag"/>
                        </div>
                        
                        {{
                        item.discountPrice!=null?(item.discountPrice/100).toFixed(2):null }}
                    </div>
                </div>
                <!-- <img
                    :src="item.showImage" :alt="item.productName" onerror="this.src='/src/assets/images/logo3.png'"
                    class="fl"> -->



                <span class="courseInfo fr"><span class="courseTitle">{{ item.name }}</span>
                   <div v-if="item.skuAttrs" class="skus">
                    <span class="sku" v-for="item1,i in item.skuAttrs.anquanyuana" :key="i">{{ item1 }}</span>
                   </div>
                   <span class="courseSubTitle" v-if="item.days">有效期:{{
                        item.days }}天</span>



                    <span class="priceWrap">
                        <!-- <span style="vertical-align: -webkit-baseline-middle;">折扣价：</span><span
                            class="unit">￥</span><span class="price">{{
                                item.discountPrice }}</span>
         
                        <span style="vertical-align: -webkit-baseline-middle;margin-left: 40px;">天猫价：</span><span
                            class="unit">￥</span><span class="price">{{
                                item.tmPrice }}</span> -->

                        <el-button class="buy-btn" type="primary" v-if="showBuyBtn"
                            @click="emits('buyNow', item)">立即购买</el-button>
                    </span>

                </span>

            </a></li>

    </ul>
</template>
<script setup>
import Tag from '@/components/common/Tag.vue';
// import { ref, reactive, onMounted, onBeforeMount, onBeforeUnmount, onUnmounted, onActivated, onDeactivated } from 'vue'

const emits = defineEmits(['buyNow'])
const props = defineProps({
    courseList: {
        type: Array,
        default: []
    },
    href: {
        type: String,
        default: '/selectCourse/detail'
    },
    canGo: {
        type: Boolean,
        default: false,
    },
    showBuyBtn: {
        type: Boolean,
        default: true,
    }
})
const router = useRouter()

function go(item) {
    if (!props.canGo) return;
    router.push(props.href)
}


// const route= useRoute()


</script>
<style scoped>
.red-text{
    color: var(--red_n);
    font-size: 30px;
}
.tag-wrap{
    display: flex;
    flex-wrap: wrap;
}
.my-tag+.my-tag{
    margin-left: 20px;
}
.courseList {
    width: 1000px;
    margin: 0 auto;
    padding-top: 20px;
}





ul.courseList>li:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 20px 0 rgba(0, 0, 0, .05);
    cursor: pointer;
}

ul.courseList>li a {
    display: block;
    width: 100%;
    color: #333;
}


ul.courseList>li a img {
    width: 114px;
    height: 114px;
    border-radius: 10px;
}




ul.courseList>li a span.courseInfo {
    display: block;
    width: 720px;
    line-height: normal;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}





ul.courseList>li a span.courseInfo .courseTitle {

    font-size: 18px;
    font-weight: 600;
}

ul.courseList>li a span.courseInfo .courseSubTitle {
    font-size: 14px;
    margin-top: 10px;
}

ul.courseList>li a span.courseInfo>span {
    display: block;
}

ul.courseList>li a span.courseInfo .priceWrap {
    margin-top: 20px;
    color: var(--red_n);
    font-size: 12px;

}

ul.courseList>li a span.courseInfo .priceWrap .unit {
    font-weight: 600;
    vertical-align: -webkit-baseline-middle;
}

ul.courseList>li a span.courseInfo .priceWrap span {
    display: inline-block;
}

ul.courseList>li a span.courseInfo .priceWrap .price {
    font-size: 24px;
    font-weight: 600;
    vertical-align: middle;
}

ul.courseList>li a span.courseInfo .priceWrap .textQi {
    vertical-align: -webkit-baseline-middle;
}


/* ul.courseList>li+li {
    margin-top: 20px;
} */


ul.courseList>li {
    width: 960px;
    padding: 20px;
    box-sizing: border-box;
    height: 164px;
    background-clip: border-box;
    /* url('@/assets/images/Rectangle 34625509.png'), */

    /* background-image:
        url('@/assets/images/Intersect.png'),
        url('@/assets/images/Rectangle 34625507.png'),
        
        url('@/assets/images/Rectangle 34625508.png'),
        url('@/assets/images/Rectangle 34625506.png'); */
    background-size: 810px 164px, 810px 164px, 960px 150px, 920px 100%;
    background-repeat: no-repeat;
    background-position: 150px 0, 150px 0, 0 7px, 100px 0;


    box-shadow: 0 1px 10px -2px rgba(0, 0, 0, .04);
    border-radius: 20px;
    border: 1px solid var(--gray_95);
    -webkit-transition: all .2s;
    transition: all .2s;
}

.buy-btn {
    float: right;
}
.sku + .sku{
    margin-left: 15px;
}
.sku{
    
    border: 1px solid white;
    border-radius: 5px;
    padding: 0 5px;
}
.skus{
    margin-top: 10px;
    
}
.courseTitle,.sku,.courseSubTitle{
    color: white;
}

ul.courseList>li:nth-child(3n){
    background-image:
        url('@/assets/images/Intersect.png'),
        url('@/assets/images/Rectangle 34625507.png'),
        url('@/assets/images/Rectangle 34625508.png'),
        url('@/assets/images/Rectangle 34625506.png');
}
ul.courseList>li:nth-child(3n+1){
    background-image:
        url('@/assets/images/Intersect.png'),
        url('@/assets/images/Rectangle 34625507.png'),
        url('@/assets/images/Rectangle 34625508.png'),
        url('@/assets/images/Rectangle 34625506.png');
}
ul.courseList>li:nth-child(3n+2){
    background-image:
        url('@/assets/images/Intersect.png'),
        url('@/assets/images/Rectangle 34625507.png'),
        url('@/assets/images/Rectangle 34625508.png'),
        url('@/assets/images/Rectangle 34625506.png');
}
</style>